package com.yungu.swift.api.route.v1.common;

import com.yungu.swift.api.utils.FileUploadUtil;
import com.yungu.swift.base.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;


/**
 * 描述：外部上传文件接口
 *
 * @author Zerrion
 */
@Controller
@RequestMapping("/api/v1/upload")
@Api(value = "系统上传接口", tags = "系统上传接口")
public class UploadApi {

    @RequestMapping(value = {"/image"}, method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    @ApiOperation(value = "上传图片接口", response = ResponseData.class)
    public ResponseData<String> uploadImage(@RequestParam MultipartFile file,
                                            @RequestParam String appid,
                                            @RequestParam String mobile,
                                            @RequestParam String imageType) {

        return FileUploadUtil.uploadImage(file, appid, mobile, imageType);
    }

    @RequestMapping(value = {"/file"})
    @ResponseBody
    @ApiOperation(value = "上传文件接口", response = ResponseData.class)
    public ResponseData<String> uploadFile(@RequestParam MultipartFile file,
                                           @RequestParam String mobile,
                                           @RequestParam String appid) {
        return FileUploadUtil.uploadFile(file, appid, mobile);
    }
}
